<script setup>
import {Notification} from "@arco-design/web-vue";
import {ref} from "vue";

const emits = defineEmits(["success"]);
const visible = ref(false);
const dir = ref('')

const handleSubmit = (done) => {
  emits('success')
  done()
};
const onSuccess = (fileItem) => {
  if (fileItem.response.code !== 0) {
    Notification.error(fileItem.response.msg)
  } else {
    Notification.success(fileItem.response.msg)
  }
}

const show = (path) => {
  dir.value = path
  visible.value = true;
};

defineExpose({show});
</script>

<template>
  <a-modal
      v-model:visible="visible"
      title="上传文件"
      ok-text="关闭上传窗口"
      :hideCancel="true"
      :mask-closable="false"
      @before-ok="handleSubmit"
      width="50%"
      style="min-width: 600px"
  >
    <div class="flex-column">
      <div class="flex-row">
        <span>上传路径：</span>
        <b>{{ dir }}</b>
      </div>
      <a-upload @success="onSuccess" :data="{path:dir}" draggable action="/api/dir/upload"/>
    </div>
  </a-modal>
</template>

<style scoped>

</style>